package org.baojie.raft.message;

import org.baojie.raft.message.info.AbstractMessage;
import org.baojie.raft.message.info.MessageInfo;
import org.baojie.raft.node.NodeName;

import java.io.Serializable;

public class RaftMessage extends AbstractMessage implements Serializable {

    private static final long serialVersionUID = -2054531882905449037L;

    private final String msgId;
    private final MessageInfo info;
    private final NodeName from;
    private final NodeName remote;

    public RaftMessage(String msgId, MessageInfo info, NodeName from, NodeName remote) {
        this.msgId = msgId;
        this.info = info;
        this.from = from;
        this.remote = remote;
    }

    public MessageInfo getMessage() {
        return info;
    }

    public String getMsgId() {
        return msgId;
    }

    @Override
    public NodeName from() {
        return from;
    }

    @Override
    public NodeName remote() {
        return remote;
    }

    @Override
    public String toString() {
        return "RaftMessage{" +
                "msgId='" + msgId + '\'' +
                ", info=" + info +
                ", from=" + from +
                ", remote=" + remote +
                '}';
    }
}
